home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Tool Chest / !Interfaces / Universal Interfaces 2.0a1 / CIncludes / Components.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-17  |  11.1 KB  |  301 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        Components.h
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a1.  ETO #15, MPW prerelease.  Sunday, July 17, 1994. 
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. */
  16.  
  17. #ifndef __COMPONENTS__
  18. #define __COMPONENTS__
  19.  
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24. /*    #include <ConditionalMacros.h>                                */
  25.  
  26. #ifndef __MIXEDMODE__
  27. #include <MixedMode.h>
  28. #endif
  29.  
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33.  
  34. #if GENERATINGPOWERPC
  35. #pragma options align=mac68k
  36. #endif
  37.  
  38. #ifdef __CFM68K__
  39. #pragma lib_export on
  40. #endif
  41.  
  42.  
  43. enum {
  44.     kAppleManufacturer            = 'appl',                        /* Apple supplied components */
  45.     kComponentResourceType        = 'thng'
  46. };
  47.  
  48. enum {
  49.     kAnyComponentType            = 0,
  50.     kAnyComponentSubType        = 0,
  51.     kAnyComponentManufacturer    = 0,
  52.     kAnyComponentFlagsMask        = 0
  53. };
  54.  
  55. enum {
  56.     cmpWantsRegisterMessage        = 1L << 31
  57. };
  58.  
  59. enum {
  60.     kComponentOpenSelect        = -1,                            /* ComponentInstance for this open */
  61.     kComponentCloseSelect        = -2,                            /* ComponentInstance for this close */
  62.     kComponentCanDoSelect        = -3,                            /* selector # being queried */
  63.     kComponentVersionSelect        = -4,                            /* no params */
  64.     kComponentRegisterSelect    = -5,                            /* no params */
  65.     kComponentTargetSelect        = -6,                            /* ComponentInstance for top of call chain */
  66.     kComponentUnregisterSelect    = -7                            /* no params */
  67. };
  68.  
  69. /* Component Resource Extension flags */
  70. enum {
  71.     componentDoAutoVersion        = (1 << 0),
  72.     componentWantsUnregister    = (1 << 1),
  73.     componentAutoVersionIncludeFlags = (1 << 2),
  74.     componentHasMultiplePlatforms = (1 << 3)
  75. };
  76.  
  77. /* Set Default Component flags */
  78. enum {
  79.     defaultComponentIdentical    = 0,
  80.     defaultComponentAnyFlags    = 1,
  81.     defaultComponentAnyManufacturer = 2,
  82.     defaultComponentAnySubType    = 4,
  83.     defaultComponentAnyFlagsAnyManufacturer = (defaultComponentAnyFlags + defaultComponentAnyManufacturer),
  84.     defaultComponentAnyFlagsAnyManufacturerAnySubType = (defaultComponentAnyFlags + defaultComponentAnyManufacturer + defaultComponentAnySubType)
  85. };
  86.  
  87. struct ComponentDescription {
  88.     OSType                            componentType;                /* A unique 4-byte code indentifying the command set */
  89.     OSType                            componentSubType;            /* Particular flavor of this instance */
  90.     OSType                            componentManufacturer;        /* Vendor indentification */
  91.     unsigned long                    componentFlags;                /* 8 each for Component,Type,SubType,Manuf/revision */
  92.     unsigned long                    componentFlagsMask;            /* Mask for specifying which flags to consider in search, zero during registration */
  93. };
  94. typedef struct ComponentDescription ComponentDescription;
  95.  
  96. struct ResourceSpec {
  97.     OSType                            resType;                    /* 4-byte code  */
  98.     short                            resID;
  99. };
  100. typedef struct ResourceSpec ResourceSpec;
  101.  
  102. struct ComponentResource {
  103.     ComponentDescription            cd;                            /* Registration parameters */
  104.     ResourceSpec                    component;                    /* resource where Component code is found */
  105.     ResourceSpec                    componentName;                /* name string resource */
  106.     ResourceSpec                    componentInfo;                /* info string resource */
  107.     ResourceSpec                    componentIcon;                /* icon resource */
  108. };
  109. typedef struct ComponentResource ComponentResource;
  110.  
  111. typedef ComponentResource *ComponentResourcePtr, **ComponentResourceHandle;
  112.  
  113. struct ComponentPlatformInfo {
  114.     long                            componentFlags;                /* flags of Component */
  115.     ResourceSpec                    component;                    /* resource where Component code is found */
  116.     short                            platformType;                /* gestaltSysArchitecture result */
  117. };
  118. typedef struct ComponentPlatformInfo ComponentPlatformInfo;
  119.  
  120. struct ComponentResourceExtension {
  121.     long                            componentVersion;            /* version of Component */
  122.     long                            componentRegisterFlags;        /* flags for registration */
  123.     short                            componentIconFamily;        /* resource id of Icon Family */
  124. };
  125. typedef struct ComponentResourceExtension ComponentResourceExtension;
  126.  
  127. struct ComponentPlatformInfoArray {
  128.     long                            count;
  129.     ComponentPlatformInfo            platformArray[1];
  130. };
  131. typedef struct ComponentPlatformInfoArray ComponentPlatformInfoArray;
  132.  
  133. struct ExtComponentResource {
  134.     ComponentDescription            cd;                            /* registration parameters */
  135.     ResourceSpec                    component;                    /* resource where Component code is found */
  136.     ResourceSpec                    componentName;                /* name string resource */
  137.     ResourceSpec                    componentInfo;                /* info string resource */
  138.     ResourceSpec                    componentIcon;                /* icon resource */
  139.     long                            componentVersion;            /* version of Component */
  140.     long                            componentRegisterFlags;        /* flags for registration */
  141.     short                            componentIconFamily;        /* resource id of Icon Family */
  142.     long                            count;                        /* elements in platformArray */
  143.     ComponentPlatformInfo            platformArray[1];
  144. };
  145. typedef struct ExtComponentResource ExtComponentResource;
  146.  
  147. struct ComponentParameters {
  148.     unsigned char                    flags;                        /* call modifiers: sync/async, deferred, immed, etc */
  149.     unsigned char                    paramSize;                    /* size in bytes of actual parameters passed to this call */
  150.     short                            what;                        /* routine selector, negative for Component management calls */
  151.     long                            params[1];                    /* actual parameters for the indicated routine */
  152. };
  153. typedef struct ComponentParameters ComponentParameters;
  154.  
  155. struct ComponentRecord {
  156.     long                            data[1];
  157. };
  158. typedef struct ComponentRecord ComponentRecord;
  159.  
  160. typedef ComponentRecord *Component;
  161.  
  162. struct ComponentInstanceRecord {
  163.     long                            data[1];
  164. };
  165. typedef struct ComponentInstanceRecord ComponentInstanceRecord;
  166.  
  167. typedef ComponentInstanceRecord *ComponentInstance;
  168.  
  169. typedef long ComponentResult;
  170.  
  171. typedef pascal ComponentResult (*ComponentRoutineProcPtr)(ComponentParameters *cp, Handle componentStorage);
  172.  
  173. #if GENERATINGCFM
  174. typedef UniversalProcPtr ComponentRoutineUPP;
  175. #else
  176. typedef ComponentRoutineProcPtr ComponentRoutineUPP;
  177. #endif
  178.  
  179. enum {
  180.     uppComponentRoutineProcInfo = kPascalStackBased
  181.          | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
  182.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ComponentParameters*)))
  183.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Handle)))
  184. };
  185.  
  186. #if GENERATINGCFM
  187. #define NewComponentRoutineProc(userRoutine)        \
  188.         (ComponentRoutineUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppComponentRoutineProcInfo, GetCurrentArchitecture())
  189. #else
  190. #define NewComponentRoutineProc(userRoutine)        \
  191.         ((ComponentRoutineUPP) (userRoutine))
  192. #endif
  193.  
  194. #if GENERATINGCFM
  195. #define CallComponentRoutineProc(userRoutine, cp, componentStorage)        \
  196.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppComponentRoutineProcInfo, (cp), (componentStorage))
  197. #else
  198. #define CallComponentRoutineProc(userRoutine, cp, componentStorage)        \
  199.         (*(userRoutine))((cp), (componentStorage))
  200. #endif
  201.  
  202. typedef ComponentRoutineProcPtr ComponentRoutine;
  203.  
  204. /*
  205.     The parameter list for each ComponentFunction is unique. It is 
  206.     therefore up to users to create the appropriate procInfo for their 
  207.     own ComponentFunctions where necessary.
  208. */
  209. typedef UniversalProcPtr ComponentFunctionUPP;
  210.  
  211. #if GENERATINGPOWERPC
  212. extern UniversalProcPtr CallComponentUPP;
  213.  
  214. #endif
  215. #define ComponentCallNow( callNumber, paramSize ) \
  216.     FIVEWORDINLINE( 0x2F3C,paramSize,callNumber,0x7000,0xA82A )
  217.  
  218. extern pascal Component RegisterComponent(ComponentDescription *cd, ComponentRoutineUPP componentEntryPoint, short global, Handle componentName, Handle componentInfo, Handle componentIcon)
  219.  TWOWORDINLINE(0x7001, 0xA82A);
  220. extern pascal Component RegisterComponentResource(ComponentResourceHandle tr, short global)
  221.  TWOWORDINLINE(0x7012, 0xA82A);
  222. extern pascal OSErr UnregisterComponent(Component aComponent)
  223.  TWOWORDINLINE(0x7002, 0xA82A);
  224. extern pascal Component FindNextComponent(Component aComponent, ComponentDescription *looking)
  225.  TWOWORDINLINE(0x7004, 0xA82A);
  226. extern pascal long CountComponents(ComponentDescription *looking)
  227.  TWOWORDINLINE(0x7003, 0xA82A);
  228. extern pascal OSErr GetComponentInfo(Component aComponent, ComponentDescription *cd, Handle componentName, Handle componentInfo, Handle componentIcon)
  229.  TWOWORDINLINE(0x7005, 0xA82A);
  230. extern pascal long GetComponentListModSeed(void)
  231.  TWOWORDINLINE(0x7006, 0xA82A);
  232. /* Component Instance Allocation and dispatch routines */
  233. extern pascal ComponentInstance OpenComponent(Component aComponent)
  234.  TWOWORDINLINE(0x7007, 0xA82A);
  235. extern pascal OSErr CloseComponent(ComponentInstance aComponentInstance)
  236.  TWOWORDINLINE(0x7008, 0xA82A);
  237. extern pascal OSErr GetComponentInstanceError(ComponentInstance aComponentInstance)
  238.  TWOWORDINLINE(0x700A, 0xA82A);
  239. /* Direct calls to the Components */
  240. extern pascal long ComponentFunctionImplemented(ComponentInstance ci, short ftnNumber)
  241.  FIVEWORDINLINE(0x2F3C, 0x2, 0xFFFD, 0x7000, 0xA82A);
  242. extern pascal long GetComponentVersion(ComponentInstance ci)
  243.  FIVEWORDINLINE(0x2F3C, 0x0, 0xFFFC, 0x7000, 0xA82A);
  244. extern pascal long ComponentSetTarget(ComponentInstance ci, ComponentInstance target)
  245.  FIVEWORDINLINE(0x2F3C, 0x4, 0xFFFA, 0x7000, 0xA82A);
  246. /* Component Management routines */
  247. extern pascal void SetComponentInstanceError(ComponentInstance aComponentInstance, OSErr theError)
  248.  TWOWORDINLINE(0x700B, 0xA82A);
  249. extern pascal long GetComponentRefcon(Component aComponent)
  250.  TWOWORDINLINE(0x7010, 0xA82A);
  251. extern pascal void SetComponentRefcon(Component aComponent, long theRefcon)
  252.  TWOWORDINLINE(0x7011, 0xA82A);
  253. extern pascal short OpenComponentResFile(Component aComponent)
  254.  TWOWORDINLINE(0x7015, 0xA82A);
  255. extern pascal OSErr CloseComponentResFile(short refnum)
  256.  TWOWORDINLINE(0x7018, 0xA82A);
  257. /* Component Instance Management routines */
  258. extern pascal Handle GetComponentInstanceStorage(ComponentInstance aComponentInstance)
  259.  TWOWORDINLINE(0x700C, 0xA82A);
  260. extern pascal void SetComponentInstanceStorage(ComponentInstance aComponentInstance, Handle theStorage)
  261.  TWOWORDINLINE(0x700D, 0xA82A);
  262. extern pascal long GetComponentInstanceA5(ComponentInstance aComponentInstance)
  263.  TWOWORDINLINE(0x700E, 0xA82A);
  264. extern pascal void SetComponentInstanceA5(ComponentInstance aComponentInstance, long theA5)
  265.  TWOWORDINLINE(0x700F, 0xA82A);
  266. extern pascal long CountComponentInstances(Component aComponent)
  267.  TWOWORDINLINE(0x7013, 0xA82A);
  268. /* Useful helper routines for convenient method dispatching */
  269. extern pascal long CallComponentFunction(ComponentParameters *params, ComponentFunctionUPP func)
  270.  TWOWORDINLINE(0x70FF, 0xA82A);
  271. extern pascal long CallComponentFunctionWithStorage(Handle storage, ComponentParameters *params, ComponentFunctionUPP func)
  272.  TWOWORDINLINE(0x70FF, 0xA82A);
  273. extern pascal long DelegateComponentCall(ComponentParameters *originalParams, ComponentInstance ci)
  274.  TWOWORDINLINE(0x7024, 0xA82A);
  275. extern pascal OSErr SetDefaultComponent(Component aComponent, short flags)
  276.  TWOWORDINLINE(0x701E, 0xA82A);
  277. extern pascal ComponentInstance OpenDefaultComponent(OSType componentType, OSType componentSubType)
  278.  TWOWORDINLINE(0x7021, 0xA82A);
  279. extern pascal Component CaptureComponent(Component capturedComponent, Component capturingComponent)
  280.  TWOWORDINLINE(0x701C, 0xA82A);
  281. extern pascal OSErr UncaptureComponent(Component aComponent)
  282.  TWOWORDINLINE(0x701D, 0xA82A);
  283. extern pascal long RegisterComponentResourceFile(short resRefNum, short global)
  284.  TWOWORDINLINE(0x7014, 0xA82A);
  285. extern pascal OSErr GetComponentIconSuite(Component aComponent, Handle *iconSuite)
  286.  TWOWORDINLINE(0x7029, 0xA82A);
  287.  
  288. #ifdef __CFM68K__
  289. #pragma lib_export off
  290. #endif
  291.  
  292. #if GENERATINGPOWERPC
  293. #pragma options align=reset
  294. #endif
  295.  
  296. #ifdef __cplusplus
  297. }
  298. #endif
  299.  
  300. #endif /* __COMPONENTS__ */
  301.